package com.wis.service.impl;

import com.wis.entity.BannerEntity;
import com.wis.mapper.BannerMapper;
import com.wis.service.BannerService;
import com.wis.util.CommonResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BannerServiceImpl implements BannerService {
    @Resource
    private BannerMapper bannerMapper;

    @Value("${server.admin.ip}")
    private String ip;
    @Value("${server.admin.port}")
    private String port;

    @Override
    public CommonResult showImg() {
        List<BannerEntity> bannerEntities = bannerMapper.showImg();
        for (BannerEntity bannerEntity : bannerEntities) {
            bannerEntity.setImg("http://" + ip + ":" + "8866" + bannerEntity.getImg());
        }
        return CommonResult.build(200, "ok", bannerEntities.size(), bannerEntities);
    }
}
